package com.cyt.work.question.service.impl;

import com.cyt.sys.service.impl.BaseServiceImpl;
import com.cyt.work.question.dao.QuestionSubjectSelectDao;
import com.cyt.work.question.model.po.QuestionSubjectSelect;
import com.cyt.work.question.model.vo.QuestionSubjectSelectVo;
import com.cyt.work.question.service.IQuestionSubjectSelectService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import java.util.List;

/**
 * 问卷题目选项表 service实现
 *
 * @author concong tao
 * @since 2019-01-31
 */
@Service
public class QuestionSubjectSelectServiceImpl extends BaseServiceImpl<QuestionSubjectSelect> implements IQuestionSubjectSelectService {

    @Autowired
    private QuestionSubjectSelectDao questionSubjectSelectDao;
    @Autowired
    public void setBaseDao(QuestionSubjectSelectDao questionSubjectSelectDao) {
        this.baseDao = questionSubjectSelectDao;
    }

    @Override
    public int insertList(List<QuestionSubjectSelect> list) {
        return questionSubjectSelectDao.insertList(list);
    }

    @Override
    public List<QuestionSubjectSelect> acceptList(QuestionSubjectSelectVo questionSubjectSelectVo) {
        Example example = new Example(QuestionSubjectSelect.class);
        Example.Criteria criteria = example.createCriteria();
        if (StringUtils.isNotBlank(questionSubjectSelectVo.getQuestionId())) {
            criteria.andEqualTo("questionId", questionSubjectSelectVo.getQuestionId());
        }
        if (StringUtils.isNotBlank(questionSubjectSelectVo.getSubjectId())) {
            criteria.andEqualTo("subjectId", questionSubjectSelectVo.getSubjectId());
        }
        example.orderBy("num");
        return questionSubjectSelectDao.selectByExample(example);
    }

    @Override
    public List<QuestionSubjectSelect> selectEntityList(QuestionSubjectSelectVo questionSubjectSelectVo) {
        return questionSubjectSelectDao.selectEntityList(questionSubjectSelectVo);
    }
}
